<template>
<div>
  <H3>{{user.name}}</H3>
</div>
</template>

<script>
import adminApi from "@/assets/api/adminApi";
export default {
  name: "index",
  data() {
    return {
      // 用户数据
      user: {
        name: 'admin'
      }
    }
  },
  mounted() {
    this.test()
  },
  methods: {
    test(){
      adminApi.test().then(r => {
        this.user.name = r.data;
        if(r.data.code === 500){
          this.$message.error(r.data.message)
        }else {
          this.$message.success("管理员测试成功")
        }
      }).catch(error => {
        this.$message.error("未登录")
        this.$router.push("/login")
      })
    }
  }
}
</script>

<style scoped>

</style>